﻿namespace Smart.ERP
{
    using Smart.Data.Helper;
    using Smart.Utils.Lib;
    using System;
    using System.Data;
    using System.Data.SqlClient;
    using System.Windows.Forms;

    public class INVENTORY_DETAIL
    {
        private int m_Action;
        private double m_Amount;
        private string m_Batch;
        private double m_Charge;
        private string m_Customer_ID;
        private string m_Description;
        private string m_Detail_No;
        private double m_Discount;
        private double m_E_Amt;
        private double m_E_ExchangeRate;
        private double m_E_Qty;
        private double m_E_Unt;
        private string m_Employee_ID;
        private double m_ExchangeRate;
        private long m_ID;
        private long m_Inventory_ID;
        private DateTime m_InventoryDate;
        private string m_InventoryNo;
        private string m_Product_ID;
        private double m_Quantity;
        private double m_SalePrice;
        private string m_Stock_ID;
        private string m_Unit;
        private double m_UnitConvert;
        private double m_UnitPrice;

        public INVENTORY_DETAIL()
        {
            this.m_ID = 0L;
            this.m_Detail_No = Guid.NewGuid().ToString();
            this.m_InventoryNo = "";
            this.m_InventoryDate = DateTime.Now;
            this.m_Inventory_ID = 0L;
            this.m_Stock_ID = "";
            this.m_Product_ID = "";
            this.m_Customer_ID = "";
            this.m_Employee_ID = "";
            this.m_Batch = "";
            this.m_Action = 0;
            this.m_Unit = "";
            this.m_UnitConvert = 0.0;
            this.m_SalePrice = 0.0;
            this.m_Discount = 0.0;
            this.m_Charge = 0.0;
            this.m_Quantity = 0.0;
            this.m_ExchangeRate = 0.0;
            this.m_UnitPrice = 0.0;
            this.m_Amount = 0.0;
            this.m_E_Qty = 0.0;
            this.m_E_ExchangeRate = 0.0;
            this.m_E_Unt = 0.0;
            this.m_E_Amt = 0.0;
            this.m_Description = "";
        }

        public INVENTORY_DETAIL(long ID, string Detail_No, string InventoryNo, DateTime InventoryDate, long Inventory_ID, string Stock_ID, string Product_ID, string Customer_ID, string Employee_ID, string Batch, int Action, string Unit, double UnitConvert, double SalePrice, double Discount, double Charge, double Quantity, double ExchangeRate, double UnitPrice, double Amount, double E_Qty, double E_ExchangeRate, double E_Unt, double E_Amt, string Description)
        {
            this.m_ID = ID;
            this.m_Detail_No = Detail_No;
            this.m_InventoryNo = InventoryNo;
            this.m_InventoryDate = InventoryDate;
            this.m_Inventory_ID = Inventory_ID;
            this.m_Stock_ID = Stock_ID;
            this.m_Product_ID = Product_ID;
            this.m_Customer_ID = Customer_ID;
            this.m_Employee_ID = Employee_ID;
            this.m_Batch = Batch;
            this.m_Action = Action;
            this.m_Unit = Unit;
            this.m_UnitConvert = UnitConvert;
            this.m_SalePrice = SalePrice;
            this.m_Discount = Discount;
            this.m_Charge = Charge;
            this.m_Quantity = Quantity;
            this.m_ExchangeRate = ExchangeRate;
            this.m_UnitPrice = UnitPrice;
            this.m_Amount = Amount;
            this.m_E_Qty = E_Qty;
            this.m_E_ExchangeRate = E_ExchangeRate;
            this.m_E_Unt = E_Unt;
            this.m_E_Amt = E_Amt;
            this.m_Description = Description;
        }

        public void AddCombo(ComboBox combo)
        {
            MyLib.TableToComboBox(combo, this.GetList(), "INVENTORY_DETAILName", "INVENTORY_DETAILID");
        }

        public void AddComboAll(ComboBox combo)
        {
            DataTable list = new DataTable();
            list = this.GetList();
            DataRow row = list.NewRow();
            row["INVENTORY_DETAILID"] = "All";
            row["INVENTORY_DETAILName"] = "Tất cả";
            list.Rows.InsertAt(row, 0);
            MyLib.TableToComboBox(combo, list, "INVENTORY_DETAILName", "INVENTORY_DETAILID");
        }

        public string Delete()
        {
            string[] myParams = new string[] { "@ID" };
            object[] myValues = new object[] { this.m_ID };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("INVENTORY_DETAIL_Delete", myParams, myValues);
        }

        public string Delete(long ID)
        {
            string[] myParams = new string[] { "@ID" };
            object[] myValues = new object[] { ID };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("INVENTORY_DETAIL_Delete", myParams, myValues);
        }

        public string Delete(SqlConnection myConnection, long ID)
        {
            string[] myParams = new string[] { "@ID" };
            object[] myValues = new object[] { ID };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "INVENTORY_DETAIL_Delete", myParams, myValues);
        }

        public string Delete(SqlTransaction myTransaction, long ID)
        {
            string[] myParams = new string[] { "@ID" };
            object[] myValues = new object[] { ID };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "INVENTORY_DETAIL_Delete", myParams, myValues);
        }

        public string Delete_Build(SqlTransaction myTransaction, string ID)
        {
            string[] myParams = new string[] { "@ID" };
            object[] myValues = new object[] { ID };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "INVENTORY_DETAIL_Delete_Build", myParams, myValues);
        }

        public string Delete_Tran_Build(SqlTransaction myTransaction, int ID)
        {
            string[] myParams = new string[] { "@ID" };
            object[] myValues = new object[] { ID };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "INVENTORY_DETAIL_Delete_Trans_Build", myParams, myValues);
        }

        public bool Exist(long ID)
        {
            bool hasRows = false;
            string[] myParams = new string[] { "@ID" };
            object[] myValues = new object[] { ID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("INVENTORY_DETAIL_Get", myParams, myValues);
            if (reader != null)
            {
                hasRows = reader.HasRows;
                reader.Close();
                helper.Close();
                reader = null;
            }
            return hasRows;
        }

        public string Get(long ID)
        {
            string str = "";
            string[] myParams = new string[] { "@ID" };
            object[] myValues = new object[] { ID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("INVENTORY_DETAIL_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_ID = Convert.ToInt64(reader["ID"]);
                    this.m_Detail_No = Convert.ToString(reader["Detail_No"]);
                    this.m_InventoryNo = Convert.ToString(reader["InventoryNo"]);
                    this.m_InventoryDate = Convert.ToDateTime(reader["InventoryDate"]);
                    this.m_Inventory_ID = Convert.ToInt64(reader["Inventory_ID"]);
                    this.m_Stock_ID = Convert.ToString(reader["Stock_ID"]);
                    this.m_Product_ID = Convert.ToString(reader["Product_ID"]);
                    this.m_Customer_ID = Convert.ToString(reader["Customer_ID"]);
                    this.m_Employee_ID = Convert.ToString(reader["Employee_ID"]);
                    this.m_Batch = Convert.ToString(reader["Batch"]);
                    this.m_Action = Convert.ToInt32(reader["Action"]);
                    this.m_Unit = Convert.ToString(reader["Unit"]);
                    this.m_UnitConvert = Convert.ToSingle(reader["UnitConvert"]);
                    this.m_SalePrice = Convert.ToSingle(reader["SalePrice"]);
                    this.m_Discount = Convert.ToSingle(reader["Discount"]);
                    this.m_Charge = Convert.ToSingle(reader["Charge"]);
                    this.m_Quantity = Convert.ToSingle(reader["Quantity"]);
                    this.m_ExchangeRate = Convert.ToSingle(reader["ExchangeRate"]);
                    this.m_UnitPrice = Convert.ToSingle(reader["UnitPrice"]);
                    this.m_Amount = Convert.ToSingle(reader["Amount"]);
                    this.m_E_Qty = Convert.ToSingle(reader["E_Qty"]);
                    this.m_E_ExchangeRate = Convert.ToSingle(reader["E_ExchangeRate"]);
                    this.m_E_Unt = Convert.ToSingle(reader["E_Unt"]);
                    this.m_E_Amt = Convert.ToSingle(reader["E_Amt"]);
                    this.m_Description = Convert.ToString(reader["Description"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public string Get(SqlConnection myConnection, long ID)
        {
            string str = "";
            string[] myParams = new string[] { "@ID" };
            object[] myValues = new object[] { ID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader(myConnection, "INVENTORY_DETAIL_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_ID = Convert.ToInt64(reader["ID"]);
                    this.m_Detail_No = Convert.ToString(reader["Detail_No"]);
                    this.m_InventoryNo = Convert.ToString(reader["InventoryNo"]);
                    this.m_InventoryDate = Convert.ToDateTime(reader["InventoryDate"]);
                    this.m_Inventory_ID = Convert.ToInt64(reader["Inventory_ID"]);
                    this.m_Stock_ID = Convert.ToString(reader["Stock_ID"]);
                    this.m_Product_ID = Convert.ToString(reader["Product_ID"]);
                    this.m_Customer_ID = Convert.ToString(reader["Customer_ID"]);
                    this.m_Employee_ID = Convert.ToString(reader["Employee_ID"]);
                    this.m_Batch = Convert.ToString(reader["Batch"]);
                    this.m_Action = Convert.ToInt32(reader["Action"]);
                    this.m_Unit = Convert.ToString(reader["Unit"]);
                    this.m_UnitConvert = Convert.ToSingle(reader["UnitConvert"]);
                    this.m_SalePrice = Convert.ToSingle(reader["SalePrice"]);
                    this.m_Discount = Convert.ToSingle(reader["Discount"]);
                    this.m_Charge = Convert.ToSingle(reader["Charge"]);
                    this.m_Quantity = Convert.ToSingle(reader["Quantity"]);
                    this.m_ExchangeRate = Convert.ToSingle(reader["ExchangeRate"]);
                    this.m_UnitPrice = Convert.ToSingle(reader["UnitPrice"]);
                    this.m_Amount = Convert.ToSingle(reader["Amount"]);
                    this.m_E_Qty = Convert.ToSingle(reader["E_Qty"]);
                    this.m_E_ExchangeRate = Convert.ToSingle(reader["E_ExchangeRate"]);
                    this.m_E_Unt = Convert.ToSingle(reader["E_Unt"]);
                    this.m_E_Amt = Convert.ToSingle(reader["E_Amt"]);
                    this.m_Description = Convert.ToString(reader["Description"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public string Get(SqlTransaction myTransaction, long ID)
        {
            string str = "";
            string[] myParams = new string[] { "@ID" };
            object[] myValues = new object[] { ID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader(myTransaction, "INVENTORY_DETAIL_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_ID = Convert.ToInt64(reader["ID"]);
                    this.m_Detail_No = Convert.ToString(reader["Detail_No"]);
                    this.m_InventoryNo = Convert.ToString(reader["InventoryNo"]);
                    this.m_InventoryDate = Convert.ToDateTime(reader["InventoryDate"]);
                    this.m_Inventory_ID = Convert.ToInt64(reader["Inventory_ID"]);
                    this.m_Stock_ID = Convert.ToString(reader["Stock_ID"]);
                    this.m_Product_ID = Convert.ToString(reader["Product_ID"]);
                    this.m_Customer_ID = Convert.ToString(reader["Customer_ID"]);
                    this.m_Employee_ID = Convert.ToString(reader["Employee_ID"]);
                    this.m_Batch = Convert.ToString(reader["Batch"]);
                    this.m_Action = Convert.ToInt32(reader["Action"]);
                    this.m_Unit = Convert.ToString(reader["Unit"]);
                    this.m_UnitConvert = Convert.ToSingle(reader["UnitConvert"]);
                    this.m_SalePrice = Convert.ToSingle(reader["SalePrice"]);
                    this.m_Discount = Convert.ToSingle(reader["Discount"]);
                    this.m_Charge = Convert.ToSingle(reader["Charge"]);
                    this.m_Quantity = Convert.ToSingle(reader["Quantity"]);
                    this.m_ExchangeRate = Convert.ToSingle(reader["ExchangeRate"]);
                    this.m_UnitPrice = Convert.ToSingle(reader["UnitPrice"]);
                    this.m_Amount = Convert.ToSingle(reader["Amount"]);
                    this.m_E_Qty = Convert.ToSingle(reader["E_Qty"]);
                    this.m_E_ExchangeRate = Convert.ToSingle(reader["E_ExchangeRate"]);
                    this.m_E_Unt = Convert.ToSingle(reader["E_Unt"]);
                    this.m_E_Amt = Convert.ToSingle(reader["E_Amt"]);
                    this.m_Description = Convert.ToString(reader["Description"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public DataTable GetList()
        {
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("INVENTORY_DETAIL_GetList");
        }

        public string Insert()
        {
            string[] myParams = new string[] { 
                "@ID", "@Detail_No", "@InventoryNo", "@InventoryDate", "@Inventory_ID", "@Stock_ID", "@Product_ID", "@Customer_ID", "@Employee_ID", "@Batch", "@Action", "@Unit", "@UnitConvert", "@SalePrice", "@Discount", "@Charge", 
                "@Quantity", "@ExchangeRate", "@UnitPrice", "@Amount", "@E_Qty", "@E_ExchangeRate", "@E_Unt", "@E_Amt", "@Description"
             };
            object[] myValues = new object[] { 
                this.m_ID, this.m_Detail_No, this.m_InventoryNo, this.m_InventoryDate, this.m_Inventory_ID, this.m_Stock_ID, this.m_Product_ID, this.m_Customer_ID, this.m_Employee_ID, this.m_Batch, this.m_Action, this.m_Unit, this.m_UnitConvert, this.m_SalePrice, this.m_Discount, this.m_Charge, 
                this.m_Quantity, this.m_ExchangeRate, this.m_UnitPrice, this.m_Amount, this.m_E_Qty, this.m_E_ExchangeRate, this.m_E_Unt, this.m_E_Amt, this.m_Description
             };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("INVENTORY_DETAIL_Insert", myParams, myValues);
        }

        public string Insert(SqlTransaction myTransaction)
        {
            string[] myParams = new string[] { 
                "@ID", "@Detail_No", "@InventoryNo", "@InventoryDate", "@Inventory_ID", "@Stock_ID", "@Product_ID", "@Customer_ID", "@Employee_ID", "@Batch", "@Action", "@Unit", "@UnitConvert", "@SalePrice", "@Discount", "@Charge", 
                "@Quantity", "@ExchangeRate", "@UnitPrice", "@Amount", "@E_Qty", "@E_ExchangeRate", "@E_Unt", "@E_Amt", "@Description"
             };
            object[] myValues = new object[] { 
                this.m_ID, this.m_Detail_No, this.m_InventoryNo, this.m_InventoryDate, this.m_Inventory_ID, this.m_Stock_ID, this.m_Product_ID, this.m_Customer_ID, this.m_Employee_ID, this.m_Batch, this.m_Action, this.m_Unit, this.m_UnitConvert, this.m_SalePrice, this.m_Discount, this.m_Charge, 
                this.m_Quantity, this.m_ExchangeRate, this.m_UnitPrice, this.m_Amount, this.m_E_Qty, this.m_E_ExchangeRate, this.m_E_Unt, this.m_E_Amt, this.m_Description
             };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "INVENTORY_DETAIL_Insert", myParams, myValues);
        }

        public string Insert(long ID, string Detail_No, string InventoryNo, DateTime InventoryDate, long Inventory_ID, string Stock_ID, string Product_ID, string Customer_ID, string Employee_ID, string Batch, int Action, string Unit, double UnitConvert, double SalePrice, double Discount, double Charge, double Quantity, double ExchangeRate, double UnitPrice, double Amount, double E_Qty, double E_ExchangeRate, double E_Unt, double E_Amt, string Description)
        {
            string[] myParams = new string[] { 
                "@ID", "@Detail_No", "@InventoryNo", "@InventoryDate", "@Inventory_ID", "@Stock_ID", "@Product_ID", "@Customer_ID", "@Employee_ID", "@Batch", "@Action", "@Unit", "@UnitConvert", "@SalePrice", "@Discount", "@Charge", 
                "@Quantity", "@ExchangeRate", "@UnitPrice", "@Amount", "@E_Qty", "@E_ExchangeRate", "@E_Unt", "@E_Amt", "@Description"
             };
            object[] myValues = new object[] { 
                ID, Detail_No, InventoryNo, InventoryDate, Inventory_ID, Stock_ID, Product_ID, Customer_ID, Employee_ID, Batch, Action, Unit, UnitConvert, SalePrice, Discount, Charge, 
                Quantity, ExchangeRate, UnitPrice, Amount, E_Qty, E_ExchangeRate, E_Unt, E_Amt, Description
             };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("INVENTORY_DETAIL_Insert", myParams, myValues);
        }

        public string Insert(SqlConnection myConnection, long ID, string Detail_No, string InventoryNo, DateTime InventoryDate, long Inventory_ID, string Stock_ID, string Product_ID, string Customer_ID, string Employee_ID, string Batch, int Action, string Unit, double UnitConvert, double SalePrice, double Discount, double Charge, double Quantity, double ExchangeRate, double UnitPrice, double Amount, double E_Qty, double E_ExchangeRate, double E_Unt, double E_Amt, string Description)
        {
            string[] myParams = new string[] { 
                "@ID", "@Detail_No", "@InventoryNo", "@InventoryDate", "@Inventory_ID", "@Stock_ID", "@Product_ID", "@Customer_ID", "@Employee_ID", "@Batch", "@Action", "@Unit", "@UnitConvert", "@SalePrice", "@Discount", "@Charge", 
                "@Quantity", "@ExchangeRate", "@UnitPrice", "@Amount", "@E_Qty", "@E_ExchangeRate", "@E_Unt", "@E_Amt", "@Description"
             };
            object[] myValues = new object[] { 
                ID, Detail_No, InventoryNo, InventoryDate, Inventory_ID, Stock_ID, Product_ID, Customer_ID, Employee_ID, Batch, Action, Unit, UnitConvert, SalePrice, Discount, Charge, 
                Quantity, ExchangeRate, UnitPrice, Amount, E_Qty, E_ExchangeRate, E_Unt, E_Amt, Description
             };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "INVENTORY_DETAIL_Insert", myParams, myValues);
        }

        public string Insert(SqlTransaction myTransaction, long ID, string Detail_No, string InventoryNo, DateTime InventoryDate, long Inventory_ID, string Stock_ID, string Product_ID, string Customer_ID, string Employee_ID, string Batch, int Action, string Unit, double UnitConvert, double SalePrice, double Discount, double Charge, double Quantity, double ExchangeRate, double UnitPrice, double Amount, double E_Qty, double E_ExchangeRate, double E_Unt, double E_Amt, string Description)
        {
            string[] myParams = new string[] { 
                "@ID", "@Detail_No", "@InventoryNo", "@InventoryDate", "@Inventory_ID", "@Stock_ID", "@Product_ID", "@Customer_ID", "@Employee_ID", "@Batch", "@Action", "@Unit", "@UnitConvert", "@SalePrice", "@Discount", "@Charge", 
                "@Quantity", "@ExchangeRate", "@UnitPrice", "@Amount", "@E_Qty", "@E_ExchangeRate", "@E_Unt", "@E_Amt", "@Description"
             };
            object[] myValues = new object[] { 
                ID, Detail_No, InventoryNo, InventoryDate, Inventory_ID, Stock_ID, Product_ID, Customer_ID, Employee_ID, Batch, Action, Unit, UnitConvert, SalePrice, Discount, Charge, 
                Quantity, ExchangeRate, UnitPrice, Amount, E_Qty, E_ExchangeRate, E_Unt, E_Amt, Description
             };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "INVENTORY_DETAIL_Insert", myParams, myValues);
        }

        public string Insert_Build(SqlTransaction myTransaction, string Detail_No, string InventoryNo, string Product_ID, string Stock_ID, DateTime InventoryDate, string Unit, double UnitConvert, double SalePrice, double Quantity, double Amount, string Description)
        {
            string[] myParams = new string[] { "@Detail_ID", "@InventoryNo", "@Product_ID", "@Stock_ID", "@Date", "@Unit", "@UnitConvert", "@UnitPrice", "@Quantity", "@Amount", "@Description" };
            object[] myValues = new object[] { Detail_No, InventoryNo, Product_ID, Stock_ID, InventoryDate, Unit, UnitConvert, SalePrice, Quantity, Amount, Description };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "INVENTORY_DETAIL_Insert_Build", myParams, myValues);
        }

        public string Insert_Trans_Build(SqlTransaction myTransaction, string Detail_No, string InventoryNo, string Product_ID, string Stock_ID, DateTime InventoryDate, string Unit, double UnitConvert, double SalePrice, double Quantity, double Amount, string Description)
        {
            string[] myParams = new string[] { "@Detail_ID", "@InventoryNo", "@Product_ID", "@Stock_ID", "@Date", "@Unit", "@UnitConvert", "@UnitPrice", "@Quantity", "@Amount", "@Description" };
            object[] myValues = new object[] { Detail_No, InventoryNo, Product_ID, Stock_ID, InventoryDate, Unit, UnitConvert, SalePrice, Quantity, Amount, Description };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "INVENTORY_DETAIL_Insert_Trans_Build", myParams, myValues);
        }

        public string NewID()
        {
            return SqlHelper.GenCode("INVENTORY_DETAIL", "InventoryNo", "PKK");
        }

        public DataTable Report_InventoryLedger(DateTime FromDate, DateTime ToDate, string Stock_ID, string Product_ID)
        {
            SqlHelper helper = new SqlHelper();
            string[] myParams = new string[] { "@FromDate", "@ToDate", "@Stock_ID", "@Product_ID" };
            object[] myValues = new object[] { FromDate, ToDate, Stock_ID, Product_ID };
            return helper.ExecuteDataTable("Report_InventoryLedger", myParams, myValues);
        }

        public DataTable Report_InventoryQuantity(DateTime FromDate, DateTime ToDate, string Stock_ID, string Product_ID)
        {
            SqlHelper helper = new SqlHelper();
            string[] myParams = new string[] { "@FromDate", "@ToDate", "@Stock_ID", "@Product_ID" };
            object[] myValues = new object[] { FromDate, ToDate, Stock_ID, Product_ID };
            return helper.ExecuteDataTable("Report_InventoryQuantity", myParams, myValues);
        }

        public DataTable Report_InventoryQuantityNoTransfer(DateTime FromDate, DateTime ToDate, string Stock_ID, string Product_ID)
        {
            SqlHelper helper = new SqlHelper();
            string[] myParams = new string[] { "@FromDate", "@ToDate", "@Stock_ID", "@Product_ID" };
            object[] myValues = new object[] { FromDate, ToDate, Stock_ID, Product_ID };
            return helper.ExecuteDataTable("Report_InventoryQuantityNoTransfer", myParams, myValues);
        }

        public DataTable Report_InventorySummary(DateTime FromDate, DateTime ToDate, string Stock_ID, string Product_ID)
        {
            SqlHelper helper = new SqlHelper();
            string[] myParams = new string[] { "@FromDate", "@ToDate", "@Stock_ID", "@Product_ID" };
            object[] myValues = new object[] { FromDate, ToDate, Stock_ID, Product_ID };
            return helper.ExecuteDataTable("Report_InventorySummary", myParams, myValues);
        }

        public DataTable Report_InventorySummaryNoTransfer(DateTime FromDate, DateTime ToDate, string Stock_ID, string Product_ID)
        {
            SqlHelper helper = new SqlHelper();
            string[] myParams = new string[] { "@FromDate", "@ToDate", "@Stock_ID", "@Product_ID" };
            object[] myValues = new object[] { FromDate, ToDate, Stock_ID, Product_ID };
            return helper.ExecuteDataTable("Report_InventorySummaryNoTransfer", myParams, myValues);
        }

        public DataTable Report_StockCard(DateTime FromDate, DateTime ToDate, string Stock_ID, string Product_ID)
        {
            SqlHelper helper = new SqlHelper();
            string[] myParams = new string[] { "@FromDate", "@ToDate", "@Stock_ID", "@Product_ID" };
            object[] myValues = new object[] { FromDate, ToDate, Stock_ID, Product_ID };
            return helper.ExecuteDataTable("REPORT_STOCK_CARD", myParams, myValues);
        }

        public DataTable Report_StockCardDN(DateTime FromDate, DateTime ToDate, string Stock_ID, string Product_ID)
        {
            SqlHelper helper = new SqlHelper();
            string[] myParams = new string[] { "@FromDate", "@ToDate", "@Stock_ID", "@Product_ID" };
            object[] myValues = new object[] { FromDate, ToDate, Stock_ID, Product_ID };
            return helper.ExecuteDataTable("REPORT_STOCK_CARD_DN", myParams, myValues);
        }

        public DataTable Summary(DateTime FromDate, DateTime ToDate, string Stock_ID, string Product_ID)
        {
            SqlHelper helper = new SqlHelper();
            string[] myParams = new string[] { "@FromDate", "@ToDate", "@Stock_ID", "@Product_ID" };
            object[] myValues = new object[] { FromDate, ToDate, Stock_ID, Product_ID };
            return helper.ExecuteDataTable("Report_Summary", myParams, myValues);
        }

        public DataTable SummaryNoTransfer(DateTime FromDate, DateTime ToDate, string Stock_ID, string Product_ID)
        {
            SqlHelper helper = new SqlHelper();
            string[] myParams = new string[] { "@FromDate", "@ToDate", "@Stock_ID", "@Product_ID" };
            object[] myValues = new object[] { FromDate, ToDate, Stock_ID, Product_ID };
            return helper.ExecuteDataTable("Report_SummaryNoTransfer", myParams, myValues);
        }

        public DataTable SummaryTranIn(DateTime FromDate, DateTime ToDate, string Stock_ID, string Product_ID)
        {
            SqlHelper helper = new SqlHelper();
            string[] myParams = new string[] { "@FromDate", "@ToDate", "@Stock_ID", "@Product_ID" };
            object[] myValues = new object[] { FromDate, ToDate, Stock_ID, Product_ID };
            return helper.ExecuteDataTable("Report_TongHopNhapLuanChuyen", myParams, myValues);
        }

        public DataTable SummaryTranOut(DateTime FromDate, DateTime ToDate, string Stock_ID, string Product_ID)
        {
            SqlHelper helper = new SqlHelper();
            string[] myParams = new string[] { "@FromDate", "@ToDate", "@Stock_ID", "@Product_ID" };
            object[] myValues = new object[] { FromDate, ToDate, Stock_ID, Product_ID };
            return helper.ExecuteDataTable("Report_TongHopXuatLuanChuyen", myParams, myValues);
        }

        public string Update()
        {
            string[] myParams = new string[] { 
                "@ID", "@Detail_No", "@InventoryNo", "@InventoryDate", "@Inventory_ID", "@Stock_ID", "@Product_ID", "@Customer_ID", "@Employee_ID", "@Batch", "@Action", "@Unit", "@UnitConvert", "@SalePrice", "@Discount", "@Charge", 
                "@Quantity", "@ExchangeRate", "@UnitPrice", "@Amount", "@E_Qty", "@E_ExchangeRate", "@E_Unt", "@E_Amt", "@Description"
             };
            object[] myValues = new object[] { 
                this.m_ID, this.m_Detail_No, this.m_InventoryNo, this.m_InventoryDate, this.m_Inventory_ID, this.m_Stock_ID, this.m_Product_ID, this.m_Customer_ID, this.m_Employee_ID, this.m_Batch, this.m_Action, this.m_Unit, this.m_UnitConvert, this.m_SalePrice, this.m_Discount, this.m_Charge, 
                this.m_Quantity, this.m_ExchangeRate, this.m_UnitPrice, this.m_Amount, this.m_E_Qty, this.m_E_ExchangeRate, this.m_E_Unt, this.m_E_Amt, this.m_Description
             };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("INVENTORY_DETAIL_Update", myParams, myValues);
        }

        public string Update(long ID, string Detail_No, string InventoryNo, DateTime InventoryDate, long Inventory_ID, string Stock_ID, string Product_ID, string Customer_ID, string Employee_ID, string Batch, int Action, string Unit, double UnitConvert, double SalePrice, double Discount, double Charge, double Quantity, double ExchangeRate, double UnitPrice, double Amount, double E_Qty, double E_ExchangeRate, double E_Unt, double E_Amt, string Description)
        {
            string[] myParams = new string[] { 
                "@ID", "@Detail_No", "@InventoryNo", "@InventoryDate", "@Inventory_ID", "@Stock_ID", "@Product_ID", "@Customer_ID", "@Employee_ID", "@Batch", "@Action", "@Unit", "@UnitConvert", "@SalePrice", "@Discount", "@Charge", 
                "@Quantity", "@ExchangeRate", "@UnitPrice", "@Amount", "@E_Qty", "@E_ExchangeRate", "@E_Unt", "@E_Amt", "@Description"
             };
            object[] myValues = new object[] { 
                ID, Detail_No, InventoryNo, InventoryDate, Inventory_ID, Stock_ID, Product_ID, Customer_ID, Employee_ID, Batch, Action, Unit, UnitConvert, SalePrice, Discount, Charge, 
                Quantity, ExchangeRate, UnitPrice, Amount, E_Qty, E_ExchangeRate, E_Unt, E_Amt, Description
             };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("INVENTORY_DETAIL_Update", myParams, myValues);
        }

        public string Update(SqlConnection myConnection, long ID, string Detail_No, string InventoryNo, DateTime InventoryDate, long Inventory_ID, string Stock_ID, string Product_ID, string Customer_ID, string Employee_ID, string Batch, int Action, string Unit, double UnitConvert, double SalePrice, double Discount, double Charge, double Quantity, double ExchangeRate, double UnitPrice, double Amount, double E_Qty, double E_ExchangeRate, double E_Unt, double E_Amt, string Description)
        {
            string[] myParams = new string[] { 
                "@ID", "@Detail_No", "@InventoryNo", "@InventoryDate", "@Inventory_ID", "@Stock_ID", "@Product_ID", "@Customer_ID", "@Employee_ID", "@Batch", "@Action", "@Unit", "@UnitConvert", "@SalePrice", "@Discount", "@Charge", 
                "@Quantity", "@ExchangeRate", "@UnitPrice", "@Amount", "@E_Qty", "@E_ExchangeRate", "@E_Unt", "@E_Amt", "@Description"
             };
            object[] myValues = new object[] { 
                ID, Detail_No, InventoryNo, InventoryDate, Inventory_ID, Stock_ID, Product_ID, Customer_ID, Employee_ID, Batch, Action, Unit, UnitConvert, SalePrice, Discount, Charge, 
                Quantity, ExchangeRate, UnitPrice, Amount, E_Qty, E_ExchangeRate, E_Unt, E_Amt, Description
             };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "INVENTORY_DETAIL_Update", myParams, myValues);
        }

        public string Update(SqlTransaction myTransaction, long ID, string Detail_No, string InventoryNo, DateTime InventoryDate, long Inventory_ID, string Stock_ID, string Product_ID, string Customer_ID, string Employee_ID, string Batch, int Action, string Unit, double UnitConvert, double SalePrice, double Discount, double Charge, double Quantity, double ExchangeRate, double UnitPrice, double Amount, double E_Qty, double E_ExchangeRate, double E_Unt, double E_Amt, string Description)
        {
            string[] myParams = new string[] { 
                "@ID", "@Detail_No", "@InventoryNo", "@InventoryDate", "@Inventory_ID", "@Stock_ID", "@Product_ID", "@Customer_ID", "@Employee_ID", "@Batch", "@Action", "@Unit", "@UnitConvert", "@SalePrice", "@Discount", "@Charge", 
                "@Quantity", "@ExchangeRate", "@UnitPrice", "@Amount", "@E_Qty", "@E_ExchangeRate", "@E_Unt", "@E_Amt", "@Description"
             };
            object[] myValues = new object[] { 
                ID, Detail_No, InventoryNo, InventoryDate, Inventory_ID, Stock_ID, Product_ID, Customer_ID, Employee_ID, Batch, Action, Unit, UnitConvert, SalePrice, Discount, Charge, 
                Quantity, ExchangeRate, UnitPrice, Amount, E_Qty, E_ExchangeRate, E_Unt, E_Amt, Description
             };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "INVENTORY_DETAIL_Update", myParams, myValues);
        }

        public string Update_Build(SqlTransaction myTransaction, string InventoryNo, string Product_ID, string Stock_ID, DateTime Date, string Unit, double UnitConvert, double UnitPrice, double Quantity, double Amount, string Description)
        {
            SqlHelper helper = new SqlHelper();
            string[] myParams = new string[] { "@InventoryNo", "@Product_ID", "@Stock_ID", "@Date", "@Unit", "@UnitConvert", "@UnitPrice", "@Quantity", "@Amount", "@Description" };
            object[] myValues = new object[] { InventoryNo, Product_ID, Stock_ID, Date, Unit, UnitConvert, UnitPrice, Quantity, Amount, Description };
            return helper.ExecuteNonQuery(myTransaction, "INVENTORY_DETAIL_Update_Build", myParams, myValues);
        }

        public int Action
        {
            get
            {
                return this.m_Action;
            }
            set
            {
                this.m_Action = value;
            }
        }

        public double Amount
        {
            get
            {
                return this.m_Amount;
            }
            set
            {
                this.m_Amount = value;
            }
        }

        public string Batch
        {
            get
            {
                return this.m_Batch;
            }
            set
            {
                this.m_Batch = value;
            }
        }

        public double Charge
        {
            get
            {
                return this.m_Charge;
            }
            set
            {
                this.m_Charge = value;
            }
        }

        public static double Count
        {
            get
            {
                SqlHelper helper = new SqlHelper();
                helper.CommandType = CommandType.Text;
                return helper.ExecuteScalar("Select Count(*) from INVENTORY_DETAIL", (double) 0.0);
            }
        }

        public string Customer_ID
        {
            get
            {
                return this.m_Customer_ID;
            }
            set
            {
                this.m_Customer_ID = value;
            }
        }

        public string Description
        {
            get
            {
                return this.m_Description;
            }
            set
            {
                this.m_Description = value;
            }
        }

        public string Detail_No
        {
            get
            {
                return this.m_Detail_No;
            }
            set
            {
                this.m_Detail_No = value;
            }
        }

        public double Discount
        {
            get
            {
                return this.m_Discount;
            }
            set
            {
                this.m_Discount = value;
            }
        }

        public double E_Amt
        {
            get
            {
                return this.m_E_Amt;
            }
            set
            {
                this.m_E_Amt = value;
            }
        }

        public double E_ExchangeRate
        {
            get
            {
                return this.m_E_ExchangeRate;
            }
            set
            {
                this.m_E_ExchangeRate = value;
            }
        }

        public double E_Qty
        {
            get
            {
                return this.m_E_Qty;
            }
            set
            {
                this.m_E_Qty = value;
            }
        }

        public double E_Unt
        {
            get
            {
                return this.m_E_Unt;
            }
            set
            {
                this.m_E_Unt = value;
            }
        }

        public string Employee_ID
        {
            get
            {
                return this.m_Employee_ID;
            }
            set
            {
                this.m_Employee_ID = value;
            }
        }

        public double ExchangeRate
        {
            get
            {
                return this.m_ExchangeRate;
            }
            set
            {
                this.m_ExchangeRate = value;
            }
        }

        public long ID
        {
            get
            {
                return this.m_ID;
            }
            set
            {
                this.m_ID = value;
            }
        }

        public long Inventory_ID
        {
            get
            {
                return this.m_Inventory_ID;
            }
            set
            {
                this.m_Inventory_ID = value;
            }
        }

        public DateTime InventoryDate
        {
            get
            {
                return this.m_InventoryDate;
            }
            set
            {
                this.m_InventoryDate = value;
            }
        }

        public string InventoryNo
        {
            get
            {
                return this.m_InventoryNo;
            }
            set
            {
                this.m_InventoryNo = value;
            }
        }

        public string Product_ID
        {
            get
            {
                return this.m_Product_ID;
            }
            set
            {
                this.m_Product_ID = value;
            }
        }

        public string ProductName
        {
            get
            {
                return "Class INVENTORY_DETAIL";
            }
        }

        public string ProductVersion
        {
            get
            {
                return "1.0.0.0";
            }
        }

        public double Quantity
        {
            get
            {
                return this.m_Quantity;
            }
            set
            {
                this.m_Quantity = value;
            }
        }

        public double SalePrice
        {
            get
            {
                return this.m_SalePrice;
            }
            set
            {
                this.m_SalePrice = value;
            }
        }

        public string Stock_ID
        {
            get
            {
                return this.m_Stock_ID;
            }
            set
            {
                this.m_Stock_ID = value;
            }
        }

        public string Unit
        {
            get
            {
                return this.m_Unit;
            }
            set
            {
                this.m_Unit = value;
            }
        }

        public double UnitConvert
        {
            get
            {
                return this.m_UnitConvert;
            }
            set
            {
                this.m_UnitConvert = value;
            }
        }

        public double UnitPrice
        {
            get
            {
                return this.m_UnitPrice;
            }
            set
            {
                this.m_UnitPrice = value;
            }
        }
    }
}

